package com.zjeav.lingjiao.ui.book;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.adapter.MetaAdapter;
import com.zjeav.lingjiao.base.baseBean.BaseApplication;
import com.zjeav.lingjiao.base.baseBean.ItemResource;
import com.zjeav.lingjiao.base.baseBean.UserBuyReCord;
import com.zjeav.lingjiao.base.response.BookDetailResponse;
import com.zjeav.lingjiao.base.tools.SharedPreferencesUtils;
import com.zjeav.lingjiao.ui.home.persenter.MainPersenter;
import com.zjeav.lingjiao.ui.home.view.NormalDecoration;
import com.zjeav.lingjiao.ui.presenter.BookPresenter;

import org.xutils.DbManager;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * 学习资料
 * @Created SiberiaDante
 * @Describe：
 * @CreateTime: 2017/12/14
 * @UpDateTime:
 * @Email: 2654828081@qq.com
 * @GitHub: https://github.com/SiberiaDante
 */

public class DynamicFragment extends LazyFragment implements MetaAdapter.ClickListener,
        BookDetailContract.View {

    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;

    private MetaAdapter adapter;
    private DbManager db;
    private BookPresenter bookPresenter;
    private static MainPersenter persenter;

    public static DynamicFragment getInstance() {
        return new DynamicFragment();

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_dynamic;
    }

    @Override
    protected void initData() {
        recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
        recyclerView.addItemDecoration(new NormalDecoration(ContextCompat.getColor(mActivity, R.color.mainGrayF8), (int) mActivity.getResources().getDimension(R.dimen.one)));

       // bookPresenter = new BookPresenter(this);
        persenter = new MainPersenter(this);
        db = BaseApplication.dbManager;

        int bookid = Integer.parseInt(SharedPreferencesUtils.getParam(getActivity(), "bookid", "0").toString());
        adapter = new MetaAdapter(getActivity(), db, this, bookid);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void lazyInitView(View view, Bundle savedInstanceState) {
    }

    @Override
    public void ItemClick(ItemResource itemResource, int type, int position, View view) {

    }

    @Override
    public void ShowBookDetail(BookDetailResponse response) {

    }

    @Override
    public void showBuyHistory(ArrayList<UserBuyReCord> list) {

    }

    @Override
    public void ShowFail(Throwable throwable) {

    }
}
